﻿package de.gameduell.framework.facebook.app.pages {
	import de.gameduell.facebook.service.gen.UserProfile;
	import de.gameduell.framework.debug.Debug;
	import de.gameduell.framework.gui.util.ToolTip;

	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.MouseEvent;

	public class InviteBuddyListItem extends BuddyListItem {

		public function InviteBuddyListItem(){
			var inviteBuddy:UserProfile = new UserProfile();
			inviteBuddy.firstName = "invite";
			inviteBuddy.highscore = "-1";		
			
			super(inviteBuddy);
			
			realName.text = _buddy.firstName;
			scoreText.text = inviteBuddy.highscore == "-1" ? "friends" : inviteBuddy.highscore;
		}
		
		override protected function checkUser():void{
			super.checkUser();
			buttonMode = true;
			mouseChildren = true;
			sprite.removeEventListener(MouseEvent.CLICK, onShowAFriendsPyramid);
			addEventListener(MouseEvent.CLICK, controller.inviteFriends);
			toolTip.active = false;
			toolTip = new ToolTip("tooltip", "inviteItem_tooltip", sprite, true);
		}
		
		override public function loadPic():void{
			try {
				var bitmapData:BitmapData = library.createBitmapData("fb_pic_square_invite", 50, 50);
				facebookPic.addChild((new Bitmap(bitmapData)));
			}catch(e:Error) {
				Debug.trace("BuddyListItem::onPicLoadError: invite fb avatar not in lib ... ", Debug.WARNING);
			}
		}
	}
}
